package com.dianhun.cn.config.es;

import com.sun.tracing.ProbeName;
import io.searchbox.client.JestClient;
import io.searchbox.client.JestClientFactory;
import io.searchbox.client.config.HttpClientConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author cyt
 * @create 2020-09-04 11:13
 */
@Configuration
public class EsConfig {
    @Bean
    public JestClient jestClient() {
        JestClientFactory factory = new JestClientFactory();
        factory.setHttpClientConfig(new HttpClientConfig
                .Builder("http://localhost:9200")
                .defaultMaxTotalConnectionPerRoute(20)
                /**
                 * Connection is still allocated
                 */
                .maxTotalConnection(20)
                .multiThreaded(true)
                .build());
        return factory.getObject();
    }
}


